package io.renren.modules.miniapp.controller;

import io.renren.common.utils.R;
import io.renren.modules.communityService.dto.MiniAppDbUserInfoDTO;
import io.renren.modules.communityService.dto.MiniAppDbUserLoginDTO;
import io.renren.modules.communityService.dto.MiniAppDbUserPayDTO;
import io.renren.modules.communityService.entity.DbUserEntity;
import io.renren.modules.communityService.service.DbUserService;
import io.renren.modules.communityService.vo.DbUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 用户表
 *
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2021-03-22 11:55:24
 */
@RestController
@RequestMapping("miniapp/dbuser")
@Api(value = "小程序用户表",tags = "小程序用户表")
public class MiniAppDbUserController {
    @Autowired
    private DbUserService dbUserService;


    /**
     * 登录
     */
    @PostMapping("/login")
    @ApiOperation(value = "登录",notes = "登录",response = DbUserEntity.class)
    public R login(@RequestBody MiniAppDbUserLoginDTO miniAppDbUserLoginDTO){
        return R.data(dbUserService.login(miniAppDbUserLoginDTO));
    }

    /**
     * 用户信息 查询水电费
     */
    @GetMapping("/info")
    @ApiOperation(value = "用户信息 查询水电费",notes = "用户信息 查询水电费",response = DbUserVO.class)
    public R info(MiniAppDbUserInfoDTO dbUser){
        return R.data(dbUserService.info(dbUser));
    }

    /**
     * 缴水电费
     */
    @PostMapping("/pay")
    @ApiOperation(value = "缴水电费",notes = "缴水电费")
    public R pay(@RequestBody MiniAppDbUserPayDTO miniAppDbUserPayDTO){
        dbUserService.pay(miniAppDbUserPayDTO);
        return R.ok();
    }


}
